package com.hj.chartdemo.viewmodel

import android.graphics.Color
import androidx.lifecycle.MutableLiveData
import com.hj.chartdemo.bean.chart.ChartData
import com.hj.chartdemo.bean.chart.ChartItemData
import com.hj.chartdemo.bean.chart.ChartTabData
import java.util.ArrayList


class ChartActivityViewModel : BaseViewModel() {

    var chartData = MutableLiveData<ChartData>()
    var pieChartData = MutableLiveData<ArrayList<ChartTabData>>()

    init {
        var ds = ArrayList<ChartItemData>()
        var colors = ArrayList<Int>()
        colors.add(Color.parseColor("#F8B551"))
        colors.add(Color.parseColor("#675cf2"))
        colors.add(Color.parseColor("#496cef"))
        colors.add(Color.parseColor("#aa63fa"))
        colors.add(Color.parseColor("#58a9f5"))
        colors.add(Color.parseColor("#58a9f5"))

        ds.add(ChartItemData("类目1","5000",colors.get(1),"valid_click_count"))
        ds.add(ChartItemData("类目2","20000",colors.get(0),"view_count"))
        ds.add(ChartItemData("类目3","500",colors.get(3),"valid_clue_count"))
        ds.add(ChartItemData("类目4","1000",colors.get(2),"clue_count"))
        ds.add(ChartItemData("类目5","50",colors.get(5),"deal_count"))
        ds.add(ChartItemData("类目6","200",colors.get(4),"arrived_count"))


        chartData.postValue(ChartData(ds,false,colors))

        val tabDatas = ArrayList<ChartTabData>()
        val chartItemData = ArrayList<ChartItemData>()
        for (index in 0 until 5){
            chartItemData.add(ChartItemData("类目"+index, "100", colors.get(index),index.toString()))
        }

        val chartData = ChartData(chartItemData, false, colors)

        val chartTabData = ChartTabData("大类1", "a", chartData)
        val chartTabData2 = ChartTabData("大类2", "b", chartData)
        val chartTabData3 = ChartTabData("大类3", "c", chartData)
        tabDatas.add(chartTabData)
        tabDatas.add(chartTabData2)
        tabDatas.add(chartTabData3)

        pieChartData.postValue(tabDatas)
    }

}
